home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / updates / update23.zoo / libg++ / src / diffcc
Encoding:
Text File  |  1992-07-20  |  51.2 KB  |  2,106 lines

  1. *** 1.5    1992/06/08 20:42:41
  2. --- Changelo    1992/07/20 22:22:32
  3. ***************
  4. *** 241,243 ****
  5. --- 241,254 ----
  6.       addition of stossc() to streambufs for ATT compatibility.
  7.   
  8.   ---------------------------- Patchlevel 12 -----------------------------------
  9. + all over:
  10. +     sync up with libg++ 2.1.9. lots of bug fixes, more accurate floating
  11. +         point i/o. this is not such a big deal for the atari.
  12. + ---------------------------- Patchlevel 12.5 (not released) ------------------
  13. + all over:
  14. +     sync up with libg++ 2.2. very minor bug fixes over libg++ 2.1.9
  15. + ---------------------------- Patchlevel 13 -----------------------------------
  16. *** 1.7    1992/06/08 20:42:41
  17. --- PatchLev.h    1992/07/20 22:22:32
  18. ***************
  19. *** 1,5 ****
  20.   
  21. ! #define    PatchLevel "12"
  22.   
  23.   /*
  24.    *    the Patch Level above is to identify the version
  25. --- 1,5 ----
  26.   
  27. ! #define    PatchLevel "13"
  28.   
  29.   /*
  30.    *    the Patch Level above is to identify the version
  31. *** 1.6    1992/06/08 20:42:41
  32. --- filebuf.cc    1992/07/20 22:22:35
  33. ***************
  34. *** 65,70 ****
  35. --- 65,73 ----
  36.   // UNBUFFERED STREAMS:
  37.   // If a filebuf is unbuffered(), the _shortbuf[1] is used as the buffer.
  38.   
  39. + #define CLOSED_FILEBUF_FLAGS \
  40. +   (_S_IS_FILEBUF+_S_NO_READS+_S_NO_WRITES+_S_TIED_PUT_GET)
  41.   void filebuf::init()
  42.   {
  43.       _fb._offset = 0;
  44. ***************
  45. *** 97,115 ****
  46.   }
  47.   
  48.   
  49. ! filebuf::filebuf() : backupbuf(_S_IS_FILEBUF+_S_NO_READS+_S_NO_WRITES)
  50.   {
  51.       init();
  52.   }
  53.   
  54. ! filebuf::filebuf(int fd) : backupbuf(_S_IS_FILEBUF+_S_NO_READS+_S_NO_WRITES)
  55.   {
  56.       init();
  57.       attach(fd);
  58.   }
  59.   
  60. ! filebuf::filebuf(int fd, char* p, size_t len)
  61. ! : backupbuf(_S_IS_FILEBUF+_S_NO_READS+_S_NO_WRITES)
  62.   {
  63.       init();
  64.       attach(fd);
  65. --- 100,117 ----
  66.   }
  67.   
  68.   
  69. ! filebuf::filebuf() : backupbuf(CLOSED_FILEBUF_FLAGS)
  70.   {
  71.       init();
  72.   }
  73.   
  74. ! filebuf::filebuf(int fd) : backupbuf(CLOSED_FILEBUF_FLAGS)
  75.   {
  76.       init();
  77.       attach(fd);
  78.   }
  79.   
  80. ! filebuf::filebuf(int fd, char* p, size_t len) : backupbuf(CLOSED_FILEBUF_FLAGS)
  81.   {
  82.       init();
  83.       attach(fd);
  84. ***************
  85. *** 139,145 ****
  86.   #endif
  87.       if ((mode & (ios::in|ios::out)) == (ios::in|ios::out)) {
  88.       posix_mode = O_RDWR;
  89. !     read_write = _S_TIED_PUT_GET;
  90.       }
  91.       else if (mode & (ios::out|ios::app))
  92.       posix_mode = O_WRONLY, read_write = _S_NO_READS;
  93. --- 141,147 ----
  94.   #endif
  95.       if ((mode & (ios::in|ios::out)) == (ios::in|ios::out)) {
  96.       posix_mode = O_RDWR;
  97. !     read_write = 0;
  98.       }
  99.       else if (mode & (ios::out|ios::app))
  100.       posix_mode = O_WRONLY, read_write = _S_NO_READS;
  101. ***************
  102. *** 165,173 ****
  103.       else if(mode & (int)ios::text)
  104.       rw_mode &= ~_S_IS_BINARY;
  105.       read_write |= rw_mode;
  106. !     xsetflags(read_write, (_S_NO_READS+_S_NO_WRITES+_S_TIED_PUT_GET)|rw_mode);
  107.   #else
  108. !     xsetflags(read_write, _S_NO_READS+_S_NO_WRITES+_S_TIED_PUT_GET);
  109.   #endif
  110.       if (mode & ios::ate) {
  111.       if (seekoff(0, ios::end) == EOF)
  112. --- 167,175 ----
  113.       else if(mode & (int)ios::text)
  114.       rw_mode &= ~_S_IS_BINARY;
  115.       read_write |= rw_mode;
  116. !     xsetflags(read_write, (_S_NO_READS+_S_NO_WRITES)|rw_mode);
  117.   #else
  118. !     xsetflags(read_write, _S_NO_READS+_S_NO_WRITES);
  119.   #endif
  120.       if (mode & ios::ate) {
  121.       if (seekoff(0, ios::end) == EOF)
  122. ***************
  123. *** 216,222 ****
  124.       }
  125.       if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+')) {
  126.       omode = O_RDWR;
  127. !     read_write = _S_TIED_PUT_GET;
  128.       }
  129.       int fdesc = ::open(filename, omode|oflags, oprot);
  130.       if (fdesc < 0)
  131. --- 218,224 ----
  132.       }
  133.       if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+')) {
  134.       omode = O_RDWR;
  135. !     read_write = 0;
  136.       }
  137.       int fdesc = ::open(filename, omode|oflags, oprot);
  138.       if (fdesc < 0)
  139. ***************
  140. *** 224,232 ****
  141.       _fb._fileno = fdesc;
  142.   #ifdef atarist
  143.       read_write |= rw_mode;
  144. !     xsetflags(read_write, (_S_NO_READS+_S_NO_WRITES+_S_TIED_PUT_GET)|rw_mode);
  145.   #else
  146. !     xsetflags(read_write, _S_NO_READS+_S_NO_WRITES+_S_TIED_PUT_GET);
  147.   #endif
  148.       _link_in();
  149.       return this;
  150. --- 226,234 ----
  151.       _fb._fileno = fdesc;
  152.   #ifdef atarist
  153.       read_write |= rw_mode;
  154. !     xsetflags(read_write, (_S_NO_READS+_S_NO_WRITES)|rw_mode);
  155.   #else
  156. !     xsetflags(read_write, _S_NO_READS+_S_NO_WRITES);
  157.   #endif
  158.       _link_in();
  159.       return this;
  160. ***************
  161. *** 253,267 ****
  162.       if (xflags() & _S_NO_WRITES) // SET ERROR
  163.       return EOF;
  164.       // Allocate a buffer if needed.
  165. !     if (pbase() == NULL) {
  166. !     if (base() == NULL)
  167. !         doallocbuf();
  168. !     if (xflags() & _S_LINE_BUF+_S_UNBUFFERED) setp(base(), base());
  169. !     else setp(base(), ebuf());
  170. !     setg(pbase(), pbase(), pbase());
  171.       }
  172.       // If currently reading, switch to writing.
  173. !     if ((_flags & _S_TIED_PUT_GET+_S_CURRENTLY_PUTTING) == _S_TIED_PUT_GET) {
  174.       if (xflags() & _S_LINE_BUF+_S_UNBUFFERED) setp(gptr(), gptr());
  175.       else setp(gptr(), ebuf());
  176.       setg(egptr(), egptr(), egptr());
  177. --- 255,269 ----
  178.       if (xflags() & _S_NO_WRITES) // SET ERROR
  179.       return EOF;
  180.       // Allocate a buffer if needed.
  181. !     if (base() == NULL) {
  182. !     doallocbuf();
  183. !     if (xflags() & _S_LINE_BUF+_S_UNBUFFERED) setp(_base, _base);
  184. !     else setp(_base, _ebuf);
  185. !     setg(_base, _base, _base);
  186. !     _flags |= _S_CURRENTLY_PUTTING;
  187.       }
  188.       // If currently reading, switch to writing.
  189. !     else if ((_flags & _S_CURRENTLY_PUTTING) == 0) {
  190.       if (xflags() & _S_LINE_BUF+_S_UNBUFFERED) setp(gptr(), gptr());
  191.       else setp(gptr(), ebuf());
  192.       setg(egptr(), egptr(), egptr());
  193. ***************
  194. *** 269,275 ****
  195.       }
  196.       if (c == EOF)
  197.       return do_flush();
  198. !     if (pptr() == ebuf()) // Buffer is really full
  199.       if (do_flush() == EOF)
  200.           return EOF;
  201.       xput_char(c);
  202. --- 271,277 ----
  203.       }
  204.       if (c == EOF)
  205.       return do_flush();
  206. !     if (pptr() == ebuf() ) // Buffer is really full
  207.       if (do_flush() == EOF)
  208.           return EOF;
  209.       xput_char(c);
  210. ***************
  211. *** 311,316 ****
  212. --- 313,319 ----
  213.           xsetflags(_S_ERR_SEEN), count = 0;
  214.       }
  215.       setg(base(), base(), base() + count);
  216. +     setp(base(), base());
  217.       if (count == 0)
  218.       return EOF;
  219.       if (_fb._offset >= 0)
  220. ***************
  221. *** 318,326 ****
  222.       return *(unsigned char*)gptr();
  223.   }
  224.   
  225. ! int filebuf::do_flush()
  226.   {
  227. -     long to_do = pptr()-pbase();
  228.       if (to_do == 0)
  229.       return 0;
  230.       if (egptr() != pbase()) {
  231. --- 321,328 ----
  232.       return *(unsigned char*)gptr();
  233.   }
  234.   
  235. ! int filebuf::do_write(const char *data, int to_do)
  236.   {
  237.       if (to_do == 0)
  238.       return 0;
  239.       if (egptr() != pbase()) {
  240. ***************
  241. *** 329,337 ****
  242.           return EOF;
  243.       _fb._offset = new_pos;
  244.       }
  245. !     _G_ssize_t count = sys_write(pbase(), to_do);
  246.       if (_cur_column)
  247. !     _cur_column = __adjust_column(_cur_column - 1, pbase(), to_do) + 1;
  248.       if (count != to_do)
  249.       return EOF;
  250.       setg(base(), base(), base());
  251. --- 331,339 ----
  252.           return EOF;
  253.       _fb._offset = new_pos;
  254.       }
  255. !     _G_ssize_t count = sys_write(data, to_do);
  256.       if (_cur_column)
  257. !     _cur_column = __adjust_column(_cur_column - 1, data, to_do) + 1;
  258.       if (count != to_do)
  259.       return EOF;
  260.       setg(base(), base(), base());
  261. ***************
  262. *** 377,384 ****
  263.       if (pptr() > pbase() || put_mode())
  264.       if (switch_to_get_mode()) return EOF;
  265.   
  266. !     allocbuf();
  267. !     // FIXME:  Will this work if get and put areas are NULL?
  268.       switch (dir) {
  269.         case ios::cur:
  270.       if (_fb._offset < 0) {
  271. --- 379,389 ----
  272.       if (pptr() > pbase() || put_mode())
  273.       if (switch_to_get_mode()) return EOF;
  274.   
  275. !     if (base() == NULL) {
  276. !     doallocbuf();
  277. !     setp(base(), base());
  278. !     setg(base(), base(), base());
  279. !     }
  280.       switch (dir) {
  281.         case ios::cur:
  282.       if (_fb._offset < 0) {
  283. ***************
  284. *** 460,465 ****
  285. --- 465,471 ----
  286.       }
  287.       }
  288.       setg(base(), base()+delta, base()+count);
  289. +     setp(base(), base());
  290.       _fb._offset = result + count;
  291.       xflags(xflags() & ~ _S_EOF_SEEN);
  292.       return offset;
  293. ***************
  294. *** 494,500 ****
  295.       setp(NULL, NULL);
  296.   
  297.       _un_link();
  298. !     _flags = _IO_MAGIC | _S_IS_FILEBUF | _S_NO_READS | _S_NO_WRITES;
  299.       _fb._fileno = EOF;
  300.       _fb._offset = 0;
  301.   
  302. --- 500,506 ----
  303.       setp(NULL, NULL);
  304.   
  305.       _un_link();
  306. !     _flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS;
  307.       _fb._fileno = EOF;
  308.       _fb._offset = 0;
  309.   
  310. ***************
  311. *** 503,509 ****
  312.   
  313.   _G_ssize_t filebuf::sys_read(char* buf, size_t size)
  314.   {
  315. !     return ::read(_fb._fileno, buf, size);
  316.   }
  317.   
  318.   fpos_t filebuf::sys_seek(fpos_t offset, _seek_dir dir)
  319. --- 509,519 ----
  320.   
  321.   _G_ssize_t filebuf::sys_read(char* buf, size_t size)
  322.   {
  323. !     for (;;) {
  324. !     _G_ssize_t count = ::read(_fb._fileno, buf, size);
  325. !     if (count != -1 || errno != EINTR)
  326. !         return count;
  327. !     }
  328.   }
  329.   
  330.   fpos_t filebuf::sys_seek(fpos_t offset, _seek_dir dir)
  331. ***************
  332. *** 516,523 ****
  333.       long to_do = n;
  334.       while (to_do > 0) {
  335.       _G_ssize_t count = ::write(fd(), buf, to_do);
  336. !     if (count == EOF)
  337. !         break;
  338.       to_do -= count;
  339.       buf += count;
  340.       }
  341. --- 526,537 ----
  342.       long to_do = n;
  343.       while (to_do > 0) {
  344.       _G_ssize_t count = ::write(fd(), buf, to_do);
  345. !     if (count == EOF) {
  346. !         if (errno == EINTR)
  347. !         continue;
  348. !         else
  349. !         break;
  350. !     }
  351.       to_do -= count;
  352.       buf += count;
  353.       }
  354. ***************
  355. *** 539,544 ****
  356. --- 553,560 ----
  357.   
  358.   size_t filebuf::sputn(const char *s, size_t n)
  359.   {
  360. +     if (n <= 0)
  361. +     return 0;
  362.       // This is an optimized implementation.
  363.       // If the amount to be written straddles a block boundary
  364.       // (or the filebuf is unbuffered), use sys_write directly.
  365. ***************
  366. *** 567,599 ****
  367.   
  368.       // Try to maintain alignment: write a whole number of blocks.
  369.       // dont_write is what gets left over.
  370. !     int block_size = _epptr - _pbase;
  371.       int dont_write = block_size >= 128 ? to_do % block_size : 0;
  372.   
  373. !     _G_ssize_t written = sys_write(s, to_do - dont_write);
  374. !     if (_cur_column)
  375. !         _cur_column = 1 + __adjust_column(_cur_column - 1,
  376. !                           s, to_do-dont_write);
  377. !     s += written;
  378. !     to_do -= written;
  379. !     if (to_do != dont_write)
  380.           return n - to_do;
  381.   
  382. !     count = _epptr - _pptr; // Space available.
  383. !     // Write out the remainder, if any.
  384. !     if (count > to_do)
  385. !         count = to_do;
  386. !     if (count > 20) {
  387. !         memcpy(pptr(), s, count);
  388. !         s += count;
  389. !     }
  390. !     else {
  391. !         register char *p = pptr();;
  392. !         for (register int i = count; --i >= 0; ) *p++ = *s++;
  393. !     }
  394. !     pbump(count);
  395. !     to_do -= count;
  396.       }
  397.       return n - to_do;
  398.   }
  399. --- 583,601 ----
  400.   
  401.       // Try to maintain alignment: write a whole number of blocks.
  402.       // dont_write is what gets left over.
  403. !     int block_size = _ebuf - _base;
  404.       int dont_write = block_size >= 128 ? to_do % block_size : 0;
  405.   
  406. !     _G_ssize_t count = to_do - dont_write;
  407. !     if (do_write(s, count) == EOF)
  408.           return n - to_do;
  409. +     to_do = dont_write;
  410.   
  411. !     // Now write out the remainder.  Normally, this will fit in the
  412. !     // buffer, but it's somewhat messier for line-buffered files,
  413. !     // so we let streambuf::sputn handle the general case.
  414. !     if (dont_write)
  415. !         to_do -= streambuf::sputn(s+count, dont_write);
  416.       }
  417.       return n - to_do;
  418.   }
  419. *** 1.2    1992/06/03 02:12:17
  420. --- fstream.cc    1992/07/20 22:22:35
  421. ***************
  422. *** 37,43 ****
  423.       _strbuf = new filebuf();
  424.       if (!rdbuf()->open(name, mode, prot))
  425.       set(ios::badbit);
  426. -     _flags &= ~ios::dont_close;
  427.   }
  428.   
  429.   ofstream::ofstream()
  430. --- 37,42 ----
  431. ***************
  432. *** 55,61 ****
  433.       _strbuf = new filebuf();
  434.       if (!rdbuf()->open(name, mode, prot))
  435.       set(ios::badbit);
  436. -     _flags &= ~ios::dont_close;
  437.   }
  438.   
  439.   #if 0
  440. --- 54,59 ----
  441. ***************
  442. *** 107,113 ****
  443.       _strbuf = new filebuf();
  444.       if (!rdbuf()->open(name, mode, prot))
  445.       set(ios::badbit);
  446. -     _flags &= ~ios::dont_close;
  447.   }
  448.   
  449.   void fstream::open(const char *name, int mode, int prot=0664)
  450. --- 105,110 ----
  451. *** 1.1    1992/03/22 07:42:32
  452. --- gnuaux.c    1992/07/20 22:22:35
  453. ***************
  454. *** 83,93 ****
  455.     return __set_new_handler (handler);
  456.   }
  457.   
  458.   static void
  459.   default_new_handler ()
  460.   {
  461.     /* don't use fprintf (stderr, ...) because it may need to call malloc.  */
  462. !   write (2, "default_new_handler: out of memory... aaaiiiiiieeeeeeeeeeeeee!\n", 65);
  463.     /* don't call exit () because that may call global destructors which
  464.        may cause a loop.  */
  465.     _exit (-1);
  466. --- 83,94 ----
  467.     return __set_new_handler (handler);
  468.   }
  469.   
  470. + #define MESSAGE "default_new_handler: out of memory... aaaiiiiiieeeeeeeeeeeeee!\n"
  471.   static void
  472.   default_new_handler ()
  473.   {
  474.     /* don't use fprintf (stderr, ...) because it may need to call malloc.  */
  475. !   _write (2, MESSAGE, sizeof(MESSAGE));
  476.     /* don't call exit () because that may call global destructors which
  477.        may cause a loop.  */
  478.     _exit (-1);
  479. *** 1.2    1992/06/03 02:12:17
  480. --- igetline.cc    1992/07/20 22:22:36
  481. ***************
  482. *** 80,88 ****
  483.       long old_total = total;
  484.       total += count;
  485.       if (ch != EOF && ch != terminator) {
  486.       ptr = _sb_readline(sb, total, terminator);
  487. !     if (ptr)
  488.           memcpy(ptr + old_total, buf, count);
  489.       return ptr;
  490.       }
  491.       
  492. --- 80,91 ----
  493.       long old_total = total;
  494.       total += count;
  495.       if (ch != EOF && ch != terminator) {
  496. +     total++; // Include ch in total.
  497.       ptr = _sb_readline(sb, total, terminator);
  498. !     if (ptr) {
  499.           memcpy(ptr + old_total, buf, count);
  500. +         ptr[old_total+count] = ch;
  501. +     }
  502.       return ptr;
  503.       }
  504.       
  505. *** 1.6    1992/06/08 20:42:41
  506. --- iostream.cc    1992/07/20 22:22:37
  507. ***************
  508. *** 31,58 ****
  509.   
  510.   extern backupbuf not_open_filebuf;
  511.   
  512. ! istream::istream() : ios(¬_open_filebuf)
  513.   {
  514.       _flags |= ios::dont_close;
  515.       _gcount = 0;
  516. -     _tie = NULL;
  517.   }
  518.   
  519. - istream::istream(streambuf *sb, ostream* tied) : ios(sb)
  520. - {
  521. -     _flags |= ios::dont_close;
  522. -     _gcount = 0;
  523. -     _tie = tied;
  524. - }
  525. - istream::~istream()
  526. - {
  527. -     if (!(_flags & (unsigned int)ios::dont_close))
  528. -     delete _strbuf;
  529. -     _flags |= ios::dont_close;
  530. -     _strbuf = ¬_open_filebuf;
  531. - }
  532.   int skip_ws(streambuf* sb)
  533.   {
  534.       int ch;
  535. --- 31,42 ----
  536.   
  537.   extern backupbuf not_open_filebuf;
  538.   
  539. ! istream::istream(streambuf *sb, ostream* tied) : ios(sb, tied)
  540.   {
  541.       _flags |= ios::dont_close;
  542.       _gcount = 0;
  543.   }
  544.   
  545.   int skip_ws(streambuf* sb)
  546.   {
  547.       int ch;
  548. ***************
  549. *** 140,146 ****
  550.       if (ipfx0()) {
  551.       va_list ap;
  552.       va_start(ap, format);
  553. !     _strbuf->vscan(format, ap);
  554.       va_end(ap);
  555.       }
  556.       return *this;
  557. --- 124,130 ----
  558.       if (ipfx0()) {
  559.       va_list ap;
  560.       va_start(ap, format);
  561. !     _strbuf->vscan(format, ap, &_state);
  562.       va_end(ap);
  563.       }
  564.       return *this;
  565. ***************
  566. *** 149,155 ****
  567.   istream& istream::vscan(const char *format, _G_va_list args)
  568.   {
  569.       if (ipfx0())
  570. !     _strbuf->vscan(format, args);
  571.       return *this;
  572.   }
  573.   
  574. --- 133,139 ----
  575.   istream& istream::vscan(const char *format, _G_va_list args)
  576.   {
  577.       if (ipfx0())
  578. !     _strbuf->vscan(format, args, &_state);
  579.       return *this;
  580.   }
  581.   
  582. ***************
  583. *** 254,266 ****
  584.           digit = ch - 'a' + 10;
  585.       else
  586.           digit = 999;
  587. !     if (digit >= base)
  588.           if (ndigits == 0)
  589.           goto fail;
  590. !         else {
  591. !         sb->sputbackc(ch);
  592.           return 1;
  593. !         }
  594.       ndigits++;
  595.       val = base * val + digit;
  596.       ch = sb->sbumpc();
  597. --- 238,250 ----
  598.           digit = ch - 'a' + 10;
  599.       else
  600.           digit = 999;
  601. !     if (digit >= base) {
  602. !         sb->sputbackc(ch);
  603.           if (ndigits == 0)
  604.           goto fail;
  605. !         else
  606.           return 1;
  607. !     }
  608.       ndigits++;
  609.       val = base * val + digit;
  610.       ch = sb->sbumpc();
  611. ***************
  612. *** 369,375 ****
  613.       int buf_len = strlen(buf);
  614.       int w = stream.width(0);
  615.       int show_pos = 0;
  616. -     int i;
  617.   
  618.       // Calculate padding.
  619.       int len = buf_len;
  620. --- 353,358 ----
  621. ***************
  622. *** 380,400 ****
  623.   
  624.       // Do actual output.
  625.       register streambuf* sbuf = stream.rdbuf();
  626. !     unsigned long pad_kind =
  627.       stream.flags() & (ios::left|ios::right|ios::internal);
  628.       char fill_char = stream.fill();
  629. !     if (pad_kind != (unsigned long)ios::left // Default (right) adjustment.
  630. !     && pad_kind != (unsigned long)ios::internal)
  631. !     for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
  632.       if (neg) sbuf->sputc('-');
  633.       else if (show_pos) sbuf->sputc('+');
  634.       if (show_base_len)
  635.       sbuf->sputn(show_base, show_base_len);
  636. !     if (pad_kind == (unsigned long)ios::internal)
  637. !     for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
  638.       sbuf->sputn(buf, buf_len);
  639. !     if (pad_kind == (unsigned long)ios::left) // Left adjustment.
  640. !     for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
  641.       stream.osfx();
  642.   }
  643.   
  644. --- 363,384 ----
  645.   
  646.       // Do actual output.
  647.       register streambuf* sbuf = stream.rdbuf();
  648. !     ios::fmtflags pad_kind =
  649.       stream.flags() & (ios::left|ios::right|ios::internal);
  650.       char fill_char = stream.fill();
  651. !     if (padding > 0
  652. !     && pad_kind != (ios::fmtflags)ios::left
  653. !     && pad_kind != (ios::fmtflags)ios::internal) // Default (right) adjust.
  654. !     sbuf->padn(fill_char, padding);
  655.       if (neg) sbuf->sputc('-');
  656.       else if (show_pos) sbuf->sputc('+');
  657.       if (show_base_len)
  658.       sbuf->sputn(show_base, show_base_len);
  659. !     if (pad_kind == (ios::fmtflags)ios::internal && padding > 0)
  660. !     sbuf->padn(fill_char, padding);
  661.       sbuf->sputn(buf, buf_len);
  662. !     if (pad_kind == (ios::fmtflags)ios::left && padding > 0) // Left adjustment
  663. !     sbuf->padn(fill_char, padding);
  664.       stream.osfx();
  665.   }
  666.   
  667. ***************
  668. *** 445,454 ****
  669.       // Uses __cvt_double (renamed from static cvt), in Chris Torek's
  670.       // stdio implementation.  The setup code uses the same logic
  671.       // as in __vsbprintf.C (also based on Torek's code).
  672. -     char negative;
  673. -     char buf[BUF];
  674.       int format_char;
  675. -     int sign = '\0';
  676.   #if 0
  677.       if (os.flags() ios::showpos) sign = '+';
  678.   #endif
  679. --- 429,435 ----
  680. ***************
  681. *** 469,474 ****
  682. --- 450,463 ----
  683.       }
  684.   
  685.       // Do actual conversion.
  686. + #ifdef USE_DTOA
  687. +     if (__outfloat(n, os.rdbuf(), format_char, os.width(0),
  688. +                os.precision(), os.flags(), 0, os.fill()) < 0)
  689. +         os.set(ios::badbit|ios::failbit); // ??
  690. + #else
  691. +     int negative;
  692. +     char buf[BUF];
  693. +     int sign = '\0';
  694.       char *cp = buf;
  695.       *cp = 0;
  696.       int size = __cvt_double(n, os.precision(),
  697. ***************
  698. *** 491,504 ****
  699.       register streambuf* sbuf = os.rdbuf();
  700.       register i;
  701.       char fill_char = os.fill();
  702. !     unsigned long pad_kind =
  703.           os.flags() & (ios::left|ios::right|ios::internal);
  704. !     if (pad_kind != (unsigned long)ios::left // Default (right) adjust.
  705. !         && pad_kind != (unsigned long)ios::internal)
  706.           for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
  707.       if (sign)
  708.           sbuf->sputc(sign);
  709. !     if (pad_kind == (unsigned long)ios::internal)
  710.           for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
  711.       
  712.       // Emit the actual concented field, followed by extra zeros.
  713. --- 480,493 ----
  714.       register streambuf* sbuf = os.rdbuf();
  715.       register i;
  716.       char fill_char = os.fill();
  717. !     ios::fmtflags pad_kind =
  718.           os.flags() & (ios::left|ios::right|ios::internal);
  719. !     if (pad_kind != (ios::fmtflags)ios::left // Default (right) adjust.
  720. !         && pad_kind != (ios::fmtflags)ios::internal)
  721.           for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
  722.       if (sign)
  723.           sbuf->sputc(sign);
  724. !     if (pad_kind == (ios::fmtflags)ios::internal)
  725.           for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
  726.       
  727.       // Emit the actual concented field, followed by extra zeros.
  728. ***************
  729. *** 505,512 ****
  730.       sbuf->sputn(cp, size);
  731.       for (i = fpprec; --i >= 0; ) sbuf->sputc('0');
  732.   
  733. !     if (pad_kind == (unsigned long)ios::left) // Left adjustment
  734.           for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
  735.       os.osfx();
  736.       }
  737.       return os;
  738. --- 494,502 ----
  739.       sbuf->sputn(cp, size);
  740.       for (i = fpprec; --i >= 0; ) sbuf->sputc('0');
  741.   
  742. !     if (pad_kind == (ios::fmtflags)ios::left) // Left adjustment
  743.           for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
  744. + #endif
  745.       os.osfx();
  746.       }
  747.       return os;
  748. ***************
  749. *** 557,580 ****
  750.       return os;
  751.   }
  752.   
  753. ! ostream::ostream() : ios(¬_open_filebuf)
  754. ! {
  755. !     _flags |= ios::dont_close;
  756. !     _tie = NULL;
  757. ! }
  758. ! ostream::ostream(streambuf* sb, ostream* tied) : ios(sb)
  759. ! {
  760. !     _flags |= ios::dont_close;
  761. !     _tie = tied;
  762. ! }
  763. ! ostream::~ostream()
  764.   {
  765. -     if (!(_flags & (unsigned int)ios::dont_close))
  766. -     delete _strbuf;
  767.       _flags |= ios::dont_close;
  768. -     _strbuf = ¬_open_filebuf;
  769.   }
  770.   
  771.   ostream& ostream::seekp(streampos pos)
  772. --- 547,555 ----
  773.       return os;
  774.   }
  775.   
  776. ! ostream::ostream(streambuf* sb, ostream* tied) : ios(sb, tied)
  777.   {
  778.       _flags |= ios::dont_close;
  779.   }
  780.   
  781.   ostream& ostream::seekp(streampos pos)
  782. ***************
  783. *** 696,720 ****
  784.   const unsigned long ios::adjustfield =
  785.       ios::left|ios::right|ios::internal;
  786.   
  787. ! iostream::iostream() : ios(¬_open_filebuf)
  788.   {
  789.       _flags |= ios::dont_close;
  790.       _gcount = 0;
  791. -     _tie = NULL;
  792. - }
  793. - iostream::iostream(streambuf* sb, ostream* tied) : ios(sb)
  794. - {
  795. -     _flags |= ios::dont_close;
  796. -     _tie = tied;
  797. - }
  798. - iostream::~iostream()
  799. - {
  800. -     if (!(_flags & (unsigned int)ios::dont_close))
  801. -     delete _strbuf;
  802. -     _flags |= ios::dont_close;
  803. -     _strbuf = ¬_open_filebuf;
  804.   }
  805.   
  806.   ostream& iostream::form(const char *format ...) // Copy of ostream::form.
  807. --- 671,680 ----
  808.   const unsigned long ios::adjustfield =
  809.       ios::left|ios::right|ios::internal;
  810.   
  811. ! iostream::iostream(streambuf* sb, ostream* tied) : ios(sb, tied)
  812.   {
  813.       _flags |= ios::dont_close;
  814.       _gcount = 0;
  815.   }
  816.   
  817.   ostream& iostream::form(const char *format ...) // Copy of ostream::form.
  818. ***************
  819. *** 730,736 ****
  820.       if (ipfx0()) {
  821.       va_list ap;
  822.       va_start(ap, format);
  823. !     _strbuf->vscan(format, ap);
  824.       va_end(ap);
  825.       }
  826.       return *this;
  827. --- 690,696 ----
  828.       if (ipfx0()) {
  829.       va_list ap;
  830.       va_start(ap, format);
  831. !     _strbuf->vscan(format, ap, &_state);
  832.       va_end(ap);
  833.       }
  834.       return *this;
  835. *** 1.5    1992/06/03 02:12:17
  836. --- mincl    1992/07/20 22:22:38
  837. ***************
  838. *** 18,24 ****
  839.   IOSRC = editbuf.cc filebuf.cc fstream.cc igetline.cc indstrea.cc iostream.cc \
  840.   makebuf.cc parsestr.cc sbufvfor.cc sbufvsca.cc sgetline.cc stdstrbu.cc \
  841.   stdstrea.cc stream.cc streambu.cc strstrea.cc xplotfil.cc xsfile.cc \
  842. ! igetsb.cc
  843.   
  844.   #
  845.   # NOTE:: dummy.o MUST be the last object on this list. otherwise you'll
  846. --- 18,24 ----
  847.   IOSRC = editbuf.cc filebuf.cc fstream.cc igetline.cc indstrea.cc iostream.cc \
  848.   makebuf.cc parsestr.cc sbufvfor.cc sbufvsca.cc sgetline.cc stdstrbu.cc \
  849.   stdstrea.cc stream.cc streambu.cc strstrea.cc xplotfil.cc xsfile.cc \
  850. ! igetsb.cc iodtoa.cc outfloat.cc
  851.   
  852.   #
  853.   # NOTE:: dummy.o MUST be the last object on this list. otherwise you'll
  854. *** 1.2    1992/06/03 02:12:17
  855. --- parsestr.cc    1992/07/20 22:22:39
  856. ***************
  857. *** 292,298 ****
  858.   {
  859.   #if 1
  860.       abort();
  861. !     return 0; // fake the compiler
  862.   #else
  863.       if (i > 0) {
  864.       size_t len = line_length();
  865. --- 292,298 ----
  866.   {
  867.   #if 1
  868.       abort();
  869. !     return 0; // Suppress warning.
  870.   #else
  871.       if (i > 0) {
  872.       size_t len = line_length();
  873. *** 1.5    1992/06/08 20:42:41
  874. --- regex.cc    1992/07/20 22:22:39
  875. ***************
  876. *** 287,293 ****
  877.      necessary.  */
  878.   #define PATFETCH(c)                            \
  879.     {if (p == pend) goto end_of_pattern;                    \
  880. !   c = * (unsigned char *) p++;                        \
  881.     if (translate) c = translate[c]; }
  882.   
  883.   /* Fetch the next character in the uncompiled pattern, with no
  884. --- 287,293 ----
  885.      necessary.  */
  886.   #define PATFETCH(c)                            \
  887.     {if (p == pend) goto end_of_pattern;                    \
  888. !   c = * (const unsigned char *) p++;                        \
  889.     if (translate) c = translate[c]; }
  890.   
  891.   /* Fetch the next character in the uncompiled pattern, with no
  892. ***************
  893. *** 294,300 ****
  894.      translation.  */
  895.   #define PATFETCH_RAW(c)                            \
  896.    {if (p == pend) goto end_of_pattern;                    \
  897. !   c = * (unsigned char *) p++; }
  898.   
  899.   #define PATUNFETCH p--
  900.   
  901. --- 294,300 ----
  902.      translation.  */
  903.   #define PATFETCH_RAW(c)                            \
  904.    {if (p == pend) goto end_of_pattern;                    \
  905. !   c = * (const unsigned char *) p++; }
  906.   
  907.   #define PATUNFETCH p--
  908.   
  909. ***************
  910. *** 385,394 ****
  911.   re_compile_pattern (const char *pattern, int size, struct re_pattern_buffer *bufp)
  912.   {
  913.     register char *b = bufp->buffer;
  914. !   register char *p = pattern;
  915. !   char *pend = pattern + size;
  916.     register unsigned c, c1;
  917. !   char *p1;
  918.     unsigned char *translate = (unsigned char *) bufp->translate;
  919.   
  920.     /* Address of the count-byte of the most recently inserted `exactn'
  921. --- 385,394 ----
  922.   re_compile_pattern (const char *pattern, int size, struct re_pattern_buffer *bufp)
  923.   {
  924.     register char *b = bufp->buffer;
  925. !   register const char *p = pattern;
  926. !   const char *pend = pattern + size;
  927.     register unsigned c, c1;
  928. !   const char *p1;
  929.     unsigned char *translate = (unsigned char *) bufp->translate;
  930.   
  931.     /* Address of the count-byte of the most recently inserted `exactn'
  932. ***************
  933. *** 429,435 ****
  934.   
  935.     /* Place in pattern (i.e., the {) to which to go back if the interval
  936.        is invalid.  */
  937. !   char *beg_interval = 0;
  938.     
  939.     /* Stack of information saved by \( and restored by \).
  940.        Four stack elements are pushed by each \(:
  941. --- 429,435 ----
  942.   
  943.     /* Place in pattern (i.e., the {) to which to go back if the interval
  944.        is invalid.  */
  945. !   const char *beg_interval = 0;
  946.     
  947.     /* Stack of information saved by \( and restored by \).
  948.        Four stack elements are pushed by each \(:
  949. ***************
  950. *** 479,485 ****
  951.       {
  952.       case '$':
  953.         {
  954. !         char *p1 = p;
  955.           /* When testing what follows the $,
  956.              look past the \-constructs that don't consume anything.  */
  957.           if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS))
  958. --- 479,485 ----
  959.       {
  960.       case '$':
  961.         {
  962. !         const char *p1 = p;
  963.           /* When testing what follows the $,
  964.              look past the \-constructs that don't consume anything.  */
  965.           if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS))
  966. *** 1.4    1992/06/03 02:12:17
  967. --- sbufvfor.cc    1992/07/20 22:22:39
  968. ***************
  969. *** 123,132 ****
  970.   
  971.   int streambuf::vform(char const *fmt0, _G_va_list ap)
  972.   {
  973. !     register char *fmt;    /* format string */
  974.       register int ch;    /* character from fmt */
  975.       register int n;        /* handy integer (short term usage) */
  976.       register char *cp;    /* handy char pointer (short term usage) */
  977.       register int flags;    /* flags as above */
  978.       int ret;        /* return value accumulator */
  979.       int width;        /* width from format (%8d), or 0 */
  980. --- 123,133 ----
  981.   
  982.   int streambuf::vform(char const *fmt0, _G_va_list ap)
  983.   {
  984. !     register const char *fmt; /* format string */
  985.       register int ch;    /* character from fmt */
  986.       register int n;        /* handy integer (short term usage) */
  987.       register char *cp;    /* handy char pointer (short term usage) */
  988. +     const char *fmark;    /* for remembering a place in fmt */
  989.       register int flags;    /* flags as above */
  990.       int ret;        /* return value accumulator */
  991.       int width;        /* width from format (%8d), or 0 */
  992. ***************
  993. *** 133,139 ****
  994.       int prec;        /* precision from format (%.3d), or -1 */
  995.       char sign;        /* sign prefix (' ', '+', '-', or \0) */
  996.   #ifdef FLOATING_POINT
  997. !     char softsign;        /* temporary negative sign for floats */
  998.       double _double;        /* double precision arguments %[eEfgG] */
  999.       int fpprec;        /* `extra' floating precision in [eEfgG] */
  1000.   #endif
  1001. --- 134,140 ----
  1002.       int prec;        /* precision from format (%.3d), or -1 */
  1003.       char sign;        /* sign prefix (' ', '+', '-', or \0) */
  1004.   #ifdef FLOATING_POINT
  1005. !     int softsign;        /* temporary negative sign for floats */
  1006.       double _double;        /* double precision arguments %[eEfgG] */
  1007.       int fpprec;        /* `extra' floating precision in [eEfgG] */
  1008.   #endif
  1009. ***************
  1010. *** 166,171 ****
  1011. --- 167,176 ----
  1012.   #define    PRINT(ptr, len) \
  1013.     do { if (sputn(ptr, len) != len) goto error; } while (0)
  1014.   #define    FLUSH() { }
  1015. + #if 1
  1016. + #define PAD_SP(howmany) if (padn(' ', howmany) < 0) goto error;
  1017. + #define PAD_0(howmany) if (padn('0', howmany) < 0) goto error;
  1018. + #else
  1019.   #define    PAD(howmany, with) { \
  1020.       if ((n = (howmany)) > 0) { \
  1021.           while (n > PADSIZE) { \
  1022. ***************
  1023. *** 175,180 ****
  1024. --- 180,188 ----
  1025.           PRINT(with, n); \
  1026.       } \
  1027.   }
  1028. + #define PAD_SP(howmany) PAD(howmany, blanks)
  1029. + #define PAD_0(howmany) PAD(howmany, zeroes)
  1030. + #endif
  1031.   
  1032.       /*
  1033.        * To extend shorts properly, we need both signed and unsigned
  1034. ***************
  1035. *** 193,199 ****
  1036.       if (unbuffered())
  1037.           return help_vform(this, fmt0, ap);
  1038.   
  1039. !     fmt = (char *)fmt0;
  1040.       ret = 0;
  1041.   
  1042.       /*
  1043. --- 201,207 ----
  1044.       if (unbuffered())
  1045.           return help_vform(this, fmt0, ap);
  1046.   
  1047. !     fmt = fmt0;
  1048.       ret = 0;
  1049.   
  1050.       /*
  1051. ***************
  1052. *** 200,209 ****
  1053.        * Scan the format for conversions (`%' character).
  1054.        */
  1055.       for (;;) {
  1056. !         for (cp = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++)
  1057.               /* void */;
  1058. !         if ((n = fmt - cp) != 0) {
  1059. !             PRINT(cp, n);
  1060.               ret += n;
  1061.           }
  1062.           if (ch == '\0')
  1063. --- 208,217 ----
  1064.        * Scan the format for conversions (`%' character).
  1065.        */
  1066.       for (;;) {
  1067. !         for (fmark = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++)
  1068.               /* void */;
  1069. !         if ((n = fmt - fmark) != 0) {
  1070. !             PRINT(fmark, n);
  1071.               ret += n;
  1072.           }
  1073.           if (ch == '\0')
  1074. ***************
  1075. *** 312,320 ****
  1076. --- 320,346 ----
  1077.           case 'e':
  1078.           case 'E':
  1079.           case 'f':
  1080. +         case 'F':
  1081.           case 'g':
  1082.           case 'G':
  1083.               _double = va_arg(ap, double);
  1084. + #ifdef USE_DTOA
  1085. +             {
  1086. +                 ios::fmtflags fmt_flags = 0;
  1087. +                 if (flags & ALT)
  1088. +                 fmt_flags |= ios::showpoint;
  1089. +                 if (flags & LADJUST)
  1090. +                 fmt_flags |= ios::right;
  1091. +                 if (__outfloat(_double, this, ch, width,
  1092. +                        prec < 0 ? DEFPREC : prec,
  1093. +                        fmt_flags,
  1094. +                        sign,
  1095. +                        flags & ZEROPAD ? '0' : ' ') < 0)
  1096. +                 goto error;
  1097. +             }
  1098. +             // CHECK ERROR!
  1099. +             continue;
  1100. + #else
  1101.               /*
  1102.                * don't do unrealistic precision; just pad it with
  1103.                * zeroes later, so buffer size stays rational.
  1104. ***************
  1105. *** 340,345 ****
  1106. --- 366,372 ----
  1107.               if (*cp == '\0')
  1108.                   cp++;
  1109.               break;
  1110. + #endif
  1111.   #endif /* FLOATING_POINT */
  1112.           case 'n':
  1113.               if (flags & LONGINT)
  1114. ***************
  1115. *** 510,516 ****
  1116.   
  1117.           /* right-adjusting blank padding */
  1118.           if ((flags & (LADJUST|ZEROPAD)) == 0)
  1119. !             PAD(width - realsz, blanks);
  1120.   
  1121.           /* prefix */
  1122.           if (sign) {
  1123. --- 537,543 ----
  1124.   
  1125.           /* right-adjusting blank padding */
  1126.           if ((flags & (LADJUST|ZEROPAD)) == 0)
  1127. !             PAD_SP(width - realsz);
  1128.   
  1129.           /* prefix */
  1130.           if (sign) {
  1131. ***************
  1132. *** 523,532 ****
  1133.   
  1134.           /* right-adjusting zero padding */
  1135.           if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
  1136. !             PAD(width - realsz, zeroes);
  1137.   
  1138.           /* leading zeroes from decimal precision */
  1139. !         PAD(dprec - fieldsz, zeroes);
  1140.   
  1141.           /* the string or number proper */
  1142.           PRINT(cp, size);
  1143. --- 550,559 ----
  1144.   
  1145.           /* right-adjusting zero padding */
  1146.           if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
  1147. !             PAD_0(width - realsz);
  1148.   
  1149.           /* leading zeroes from decimal precision */
  1150. !         PAD_0(dprec - fieldsz);
  1151.   
  1152.           /* the string or number proper */
  1153.           PRINT(cp, size);
  1154. ***************
  1155. *** 533,544 ****
  1156.   
  1157.   #ifdef FLOATING_POINT
  1158.           /* trailing f.p. zeroes */
  1159. !         PAD(fpprec, zeroes);
  1160.   #endif
  1161.   
  1162.           /* left-adjusting padding (always blank) */
  1163.           if (flags & LADJUST)
  1164. !             PAD(width - realsz, blanks);
  1165.   
  1166.           /* finally, adjust ret */
  1167.           ret += width > realsz ? width : realsz;
  1168. --- 560,571 ----
  1169.   
  1170.   #ifdef FLOATING_POINT
  1171.           /* trailing f.p. zeroes */
  1172. !         PAD_0(fpprec);
  1173.   #endif
  1174.   
  1175.           /* left-adjusting padding (always blank) */
  1176.           if (flags & LADJUST)
  1177. !             PAD_SP(width - realsz);
  1178.   
  1179.           /* finally, adjust ret */
  1180.           ret += width > realsz ? width : realsz;
  1181. ***************
  1182. *** 553,559 ****
  1183.       /* NOTREACHED */
  1184.   }
  1185.   
  1186. ! #ifdef FLOATING_POINT
  1187.   
  1188.   static char *exponent(register char *p, register int exp, int fmtch)
  1189.   {
  1190. --- 580,586 ----
  1191.       /* NOTREACHED */
  1192.   }
  1193.   
  1194. ! #if defined(FLOATING_POINT) && !defined(USE_DTOA)
  1195.   
  1196.   static char *exponent(register char *p, register int exp, int fmtch)
  1197.   {
  1198. ***************
  1199. *** 584,590 ****
  1200.   
  1201.   static char * round(double fract, int *exp,
  1202.               register char *start, register char *end,
  1203. !             char ch, char *signp)
  1204.   {
  1205.       double tmp;
  1206.   
  1207. --- 611,617 ----
  1208.   
  1209.   static char * round(double fract, int *exp,
  1210.               register char *start, register char *end,
  1211. !             char ch, int *signp)
  1212.   {
  1213.       double tmp;
  1214.   
  1215. ***************
  1216. *** 624,638 ****
  1217.       return (start);
  1218.   }
  1219.   
  1220. ! int __cvt_double(double number, register int prec, int flags, char *signp,
  1221.            int fmtch, char *startp, char *endp)
  1222.   {
  1223.       register char *p, *t;
  1224.       register double fract;
  1225. !     int dotrim, expcnt, gformat;
  1226.       double integer, tmp;
  1227.   
  1228. !     dotrim = expcnt = gformat = 0;
  1229.       if (number < 0) {
  1230.           number = -number;
  1231.           *signp = '-';
  1232. --- 651,665 ----
  1233.       return (start);
  1234.   }
  1235.   
  1236. ! int __cvt_double(double number, register int prec, int flags, int *signp,
  1237.            int fmtch, char *startp, char *endp)
  1238.   {
  1239.       register char *p, *t;
  1240.       register double fract;
  1241. !     int dotrim = 0, expcnt, gformat = 0;
  1242.       double integer, tmp;
  1243.   
  1244. !     expcnt = 0;
  1245.       if (number < 0) {
  1246.           number = -number;
  1247.           *signp = '-';
  1248. ***************
  1249. *** 654,659 ****
  1250. --- 681,687 ----
  1251.       }
  1252.       switch (fmtch) {
  1253.       case 'f':
  1254. +     case 'F':
  1255.           /* reverse integer into beginning of buffer */
  1256.           if (expcnt)
  1257.               for (; ++p < endp; *t++ = *p);
  1258. ***************
  1259. *** 812,815 ****
  1260.       return (t - startp);
  1261.   }
  1262.   
  1263. ! #endif /* FLOATING_POINT */
  1264. --- 840,843 ----
  1265.       return (t - startp);
  1266.   }
  1267.   
  1268. ! #endif /* defined(FLOATING_POINT) && !defined(USE_DTOA) */
  1269. *** 1.3    1992/06/03 02:12:17
  1270. --- sbufvsca.cc    1992/07/20 22:22:40
  1271. ***************
  1272. *** 82,92 ****
  1273.   #define u_long unsigned long
  1274.   
  1275.   extern "C" u_long strtoul(const char*, char**, int);
  1276. ! static u_char *__sccl(register char *tab, register u_char *fmt);
  1277.   
  1278. ! int streambuf::vscan(char const *fmt0, _G_va_list ap)
  1279.   {
  1280. !     register u_char *fmt = (u_char *)fmt0;
  1281.       register int c;        /* character from format, or conversion */
  1282.       register size_t width;    /* field width, or 0 */
  1283.       register char *p;    /* points into all kinds of strings */
  1284. --- 82,96 ----
  1285.   #define u_long unsigned long
  1286.   
  1287.   extern "C" u_long strtoul(const char*, char**, int);
  1288. ! static const u_char *__sccl(register char *tab, register const u_char *fmt);
  1289.   
  1290. ! // If state is non-NULL, set failbit and/or eofbit as appropriate.
  1291. ! int streambuf::vscan(char const *fmt0,
  1292. !              _G_va_list ap,
  1293. !              ios::iostate *state /* = NULL */)
  1294.   {
  1295. !     register const u_char *fmt = (const u_char *)fmt0;
  1296.       register int c;        /* character from format, or conversion */
  1297.       register size_t width;    /* field width, or 0 */
  1298.       register char *p;    /* points into all kinds of strings */
  1299. ***************
  1300. *** 101,106 ****
  1301. --- 105,111 ----
  1302.       // conversion function (strtol/strtoul)
  1303.       char ccltab[256];    /* character class table for %[...] */
  1304.       char buf[BUF];        /* buffer for numeric conversions */
  1305. +     int seen_eof = 0;
  1306.   
  1307.       /* `basefix' is used to avoid `if' tests in the integer scanner */
  1308.       static short basefix[17] =
  1309. ***************
  1310. *** 111,122 ****
  1311.       for (;;) {
  1312.           c = *fmt++;
  1313.           if (c == 0)
  1314. !             return (nassigned);
  1315.           if (isspace(c)) {
  1316.               for (;;) {
  1317.                       c = sbumpc();
  1318.                   if (c == EOF)
  1319. !                     return nassigned;
  1320.                   if (!isspace(c)) {
  1321.                       sputbackc(c);
  1322.                       break;
  1323. --- 116,127 ----
  1324.       for (;;) {
  1325.           c = *fmt++;
  1326.           if (c == 0)
  1327. !             goto done;
  1328.           if (isspace(c)) {
  1329.               for (;;) {
  1330.                       c = sbumpc();
  1331.                   if (c == EOF)
  1332. !                     goto eof_failure;
  1333.                   if (!isspace(c)) {
  1334.                       sputbackc(c);
  1335.                       break;
  1336. ***************
  1337. *** 139,145 ****
  1338.   literal:
  1339.                   n = sbumpc();
  1340.               if (n == EOF)
  1341. !                 goto input_failure;
  1342.               if (n != c) {
  1343.                   sputbackc(n);
  1344.                   goto match_failure;
  1345. --- 144,150 ----
  1346.   literal:
  1347.                   n = sbumpc();
  1348.               if (n == EOF)
  1349. !                 goto eof_failure;
  1350.               if (n != c) {
  1351.                   sputbackc(n);
  1352.                   goto match_failure;
  1353. ***************
  1354. *** 259,265 ****
  1355.            * Disgusting backwards compatibility hacks.    XXX
  1356.            */
  1357.           case '\0':    /* compat */
  1358. !             return (EOF);
  1359.   
  1360.           default:    /* compat */
  1361.               if (isupper(c))
  1362. --- 264,271 ----
  1363.            * Disgusting backwards compatibility hacks.    XXX
  1364.            */
  1365.           case '\0':    /* compat */
  1366. !                 nassigned = EOF;
  1367. !             goto done;
  1368.   
  1369.           default:    /* compat */
  1370.               if (isupper(c))
  1371. ***************
  1372. *** 274,280 ****
  1373.            * We have a conversion that requires input.
  1374.            */
  1375.           if (sgetc() == EOF)
  1376. !             goto input_failure;
  1377.   
  1378.           /*
  1379.            * Consume leading white space, except for formats
  1380. --- 280,286 ----
  1381.            * We have a conversion that requires input.
  1382.            */
  1383.           if (sgetc() == EOF)
  1384. !             goto eof_failure;
  1385.   
  1386.           /*
  1387.            * Consume leading white space, except for formats
  1388. ***************
  1389. *** 287,293 ****
  1390.               nread++;
  1391.               n = sgetc();
  1392.               if (n == EOF)
  1393. !                 goto input_failure;
  1394.               }
  1395.               // Note that there is at least one character in
  1396.               // the buffer, so conversions that do not set NOSKIP
  1397. --- 293,299 ----
  1398.               nread++;
  1399.               n = sgetc();
  1400.               if (n == EOF)
  1401. !                 goto eof_failure;
  1402.               }
  1403.               // Note that there is at least one character in
  1404.               // the buffer, so conversions that do not set NOSKIP
  1405. ***************
  1406. *** 301,307 ****
  1407.   
  1408.           case CT_CHAR:
  1409.               /* scan arbitrary characters (sets NOSKIP) */
  1410. !             if (width == 0)
  1411.                   width = 1;
  1412.               if (flags & SUPPRESS) {
  1413.                   size_t sum = 0;
  1414. --- 307,313 ----
  1415.   
  1416.           case CT_CHAR:
  1417.               /* scan arbitrary characters (sets NOSKIP) */
  1418. !             if (width == 0) // FIXME!
  1419.                   width = 1;
  1420.               if (flags & SUPPRESS) {
  1421.                   size_t sum = 0;
  1422. ***************
  1423. *** 312,320 ****
  1424.                       _gptr += n;
  1425.                       if (underflow() == EOF)
  1426.                       if (sum == 0)
  1427. !                         goto input_failure;
  1428. !                     else
  1429.                           break;
  1430.                   } else {
  1431.                       sum += width;
  1432.                       _gptr += width;
  1433. --- 318,328 ----
  1434.                       _gptr += n;
  1435.                       if (underflow() == EOF)
  1436.                       if (sum == 0)
  1437. !                         goto eof_failure;
  1438. !                     else {
  1439. !                         seen_eof++;
  1440.                           break;
  1441. +                     }
  1442.                   } else {
  1443.                       sum += width;
  1444.                       _gptr += width;
  1445. ***************
  1446. *** 325,332 ****
  1447.               } else {
  1448.                   size_t r = sgetn((char*)va_arg(ap, char*),
  1449.                            width);
  1450. !                 if (r == 0)
  1451. !                 goto input_failure;
  1452.                   nread += r;
  1453.                   nassigned++;
  1454.               }
  1455. --- 333,340 ----
  1456.               } else {
  1457.                   size_t r = sgetn((char*)va_arg(ap, char*),
  1458.                            width);
  1459. !                 if (r != width)
  1460. !                 goto eof_failure;
  1461.                   nread += r;
  1462.                   nassigned++;
  1463.               }
  1464. ***************
  1465. *** 345,351 ****
  1466.                       break;
  1467.                       if (sgetc() == EOF) {
  1468.                       if (n == 0)
  1469. !                         goto input_failure;
  1470.                       break;
  1471.                       }
  1472.                   }
  1473. --- 353,360 ----
  1474.                       break;
  1475.                       if (sgetc() == EOF) {
  1476.                       if (n == 0)
  1477. !                         goto eof_failure;
  1478. !                     seen_eof++;
  1479.                       break;
  1480.                       }
  1481.                   }
  1482. ***************
  1483. *** 359,365 ****
  1484.                       break;
  1485.                   if (sgetc() == EOF) {
  1486.                       if (p == p0)
  1487. !                     goto input_failure;
  1488.                       break;
  1489.                   }
  1490.                   }
  1491. --- 368,375 ----
  1492.                       break;
  1493.                   if (sgetc() == EOF) {
  1494.                       if (p == p0)
  1495. !                     goto eof_failure;
  1496. !                     seen_eof++;
  1497.                       break;
  1498.                   }
  1499.                   }
  1500. ***************
  1501. *** 382,389 ****
  1502.                       n++, _gptr++;
  1503.                       if (--width == 0)
  1504.                           break;
  1505. !                     if (sgetc() == EOF)
  1506. !                         break;
  1507.                   }
  1508.                   nread += n;
  1509.               } else {
  1510. --- 392,401 ----
  1511.                       n++, _gptr++;
  1512.                       if (--width == 0)
  1513.                           break;
  1514. !                     if (sgetc() == EOF) {
  1515. !                         seen_eof++;
  1516. !                         break;
  1517. !                     }
  1518.                   }
  1519.                   nread += n;
  1520.               } else {
  1521. ***************
  1522. *** 392,399 ****
  1523.                       *p++ = *_gptr++;
  1524.                       if (--width == 0)
  1525.                           break;
  1526. !                     if (sgetc() == EOF)
  1527. !                         break;
  1528.                   }
  1529.                   *p = 0;
  1530.                   nread += p - p0;
  1531. --- 404,413 ----
  1532.                       *p++ = *_gptr++;
  1533.                       if (--width == 0)
  1534.                           break;
  1535. !                     if (sgetc() == EOF) {
  1536. !                         seen_eof++;
  1537. !                         break;
  1538. !                     }
  1539.                   }
  1540.                   *p = 0;
  1541.                   nread += p - p0;
  1542. ***************
  1543. *** 499,507 ****
  1544.                    */
  1545.                   *p++ = c;
  1546.                   _gptr++;
  1547. !                 if (sgetc() == EOF)
  1548. !                     break;        /* EOF */
  1549. !             }
  1550.               /*
  1551.                * If we had only a sign, it is no good; push
  1552.                * back the sign.  If the number ends in `x',
  1553. --- 513,523 ----
  1554.                    */
  1555.                   *p++ = c;
  1556.                   _gptr++;
  1557. !                 if (sgetc() == EOF) {
  1558. !                     seen_eof++;
  1559. !                     break;        /* EOF */
  1560. !                 }
  1561. !                 }
  1562.               /*
  1563.                * If we had only a sign, it is no good; push
  1564.                * back the sign.  If the number ends in `x',
  1565. ***************
  1566. *** 589,596 ****
  1567.           fok:
  1568.                   *p++ = c;
  1569.                   _gptr++;
  1570. !                 if (sgetc() == EOF)
  1571. !                     break;    /* EOF */
  1572.               }
  1573.               /*
  1574.                * If no digits, might be missing exponent digits
  1575. --- 605,614 ----
  1576.           fok:
  1577.                   *p++ = c;
  1578.                   _gptr++;
  1579. !                 if (sgetc() == EOF) {
  1580. !                     seen_eof++;
  1581. !                     break;    /* EOF */
  1582. !                 }
  1583.               }
  1584.               /*
  1585.                * If no digits, might be missing exponent digits
  1586. ***************
  1587. *** 614,622 ****
  1588.               }
  1589.               if ((flags & SUPPRESS) == 0) {
  1590.                   double res;
  1591.                   *p = 0;
  1592.                   res = atof(buf);
  1593.                   if (flags & LONG)
  1594.                       *va_arg(ap, double *) = res;
  1595.                   else
  1596. --- 632,643 ----
  1597.               }
  1598.               if ((flags & SUPPRESS) == 0) {
  1599.                   double res;
  1600.                   *p = 0;
  1601. + #ifdef USE_DTOA
  1602. +                 res = strtod(buf, NULL);
  1603. + #else
  1604.                   res = atof(buf);
  1605. + #endif
  1606.                   if (flags & LONG)
  1607.                       *va_arg(ap, double *) = res;
  1608.                   else
  1609. ***************
  1610. *** 628,636 ****
  1611.   #endif /* FLOATING_POINT */
  1612.           }
  1613.       }
  1614.   input_failure:
  1615. !     return (nassigned ? nassigned : -1);
  1616.   match_failure:
  1617.       return (nassigned);
  1618.   }
  1619.   
  1620. --- 649,665 ----
  1621.   #endif /* FLOATING_POINT */
  1622.           }
  1623.       }
  1624. + eof_failure:
  1625. +     seen_eof++;
  1626.   input_failure:
  1627. !     if (nassigned == 0)
  1628. !         nassigned = -1;
  1629.   match_failure:
  1630. +     if (state)
  1631. +         *state |= ios::failbit;
  1632. + done:
  1633. +     if (state && seen_eof)
  1634. +         *state |= ios::eofbit;
  1635.       return (nassigned);
  1636.   }
  1637.   
  1638. ***************
  1639. *** 640,646 ****
  1640.    * closing `]'.  The table has a 1 wherever characters should be
  1641.    * considered part of the scanset.
  1642.    */
  1643. ! static u_char *__sccl(register char *tab, register u_char *fmt)
  1644.   {
  1645.       register int c, n, v;
  1646.   
  1647. --- 669,675 ----
  1648.    * closing `]'.  The table has a 1 wherever characters should be
  1649.    * considered part of the scanset.
  1650.    */
  1651. ! static const u_char *__sccl(register char *tab, register const u_char *fmt)
  1652.   {
  1653.       register int c, n, v;
  1654.   
  1655. *** 1.4    1992/06/03 02:12:17
  1656. --- streambu.cc    1992/07/20 22:22:41
  1657. ***************
  1658. *** 193,198 ****
  1659. --- 193,201 ----
  1660.   size_t streambuf::sputn(const char* s, size_t n) // OPTIMIZE THIS!
  1661.   {
  1662.       size_t count = 0;
  1663. +     if(((long)n) < 0) return 0;
  1664.       for (; count < n; count++) {
  1665.       if (sputc(*s++) == EOF)
  1666.           break;
  1667. ***************
  1668. *** 224,229 ****
  1669. --- 227,234 ----
  1670.   #else
  1671.   size_t streambuf::sputn(register const char* s, size_t n)
  1672.   {
  1673. +     if (n <= 0)
  1674. +     return 0;
  1675.       register size_t more = n;
  1676.       for (;;) {
  1677.       size_t count = _epptr - _pptr; // Space available.
  1678. ***************
  1679. *** 251,256 ****
  1680. --- 256,262 ----
  1681.       return n - more;
  1682.   }
  1683.   
  1684.   size_t streambuf::sgetn(char* s, size_t n)
  1685.   {
  1686.       register size_t more = n;
  1687. ***************
  1688. *** 297,302 ****
  1689. --- 303,335 ----
  1690.   }
  1691.   #endif /* atari */
  1692.   
  1693. + int streambuf::padn(char pad, int count)
  1694. + {
  1695. + #define PADSIZE 16
  1696. +     static char const blanks[PADSIZE] =
  1697. +      {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
  1698. +     static char const zeroes[PADSIZE] =
  1699. +      {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
  1700. +     char padbuf[PADSIZE];
  1701. +     const char *padptr;
  1702. +     register int i;
  1703. +     
  1704. +     if (pad == ' ')
  1705. +     padptr = blanks;
  1706. +     else if (pad == '0')
  1707. +     padptr = zeroes;
  1708. +     else {
  1709. +     for (i = PADSIZE; --i >= 0; ) padbuf[i] = pad;
  1710. +     padptr = padbuf;
  1711. +     }
  1712. +     for (i = count; i >= PADSIZE; i -= PADSIZE)
  1713. +     if (sputn(padptr, PADSIZE) != PADSIZE)
  1714. +         return EOF;
  1715. +     if (i > 0 && sputn(padptr, i) != i)
  1716. +     return EOF;
  1717. +     return pad;
  1718. + }
  1719.   int streambuf::sync()
  1720.   {
  1721.       if (gptr() == egptr() && pptr() == pbase())
  1722. ***************
  1723. *** 430,435 ****
  1724. --- 463,469 ----
  1725.   {
  1726.       if (gptr() <= eback()) return pbackfail(c);
  1727.       gbump(-1);
  1728. +     // Don't write into the get buffer if we don't have to.
  1729.       if (*gptr() != c)
  1730.       *gptr() = c;
  1731.       return (unsigned char)c;
  1732. ***************
  1733. *** 654,659 ****
  1734. --- 688,697 ----
  1735.       return start + count;
  1736.   }
  1737.   
  1738. + #if defined(linux)
  1739. + #define IO_CLEANUP ;
  1740. + #endif
  1741.   
  1742.   #ifdef IO_CLEANUP
  1743.     IO_CLEANUP
  1744. *** 1.5    1992/06/03 02:12:17
  1745. --- strstrea.cc    1992/07/20 22:22:41
  1746. ***************
  1747. *** 128,134 ****
  1748.   strstreambuf::strstreambuf()
  1749.   {
  1750.       _frozen = 0;
  1751. - //    _flags &= ~ios::dont_close; 
  1752.       _len = 0;
  1753.       _size = 128;
  1754.       _buffer = ALLOC_BUF(_size);
  1755. --- 128,133 ----
  1756. ***************
  1757. *** 140,146 ****
  1758.   strstreambuf::strstreambuf(int initial)
  1759.   {
  1760.       _frozen = 0;
  1761. - //    _flags &= ~ios::dont_close; 
  1762.       _len = 0;
  1763.       if (initial < 16)
  1764.       initial = 16;
  1765. --- 139,144 ----
  1766. ***************
  1767. *** 153,159 ****
  1768.   
  1769.   strstreambuf::strstreambuf(char *ptr, size_t size, char *pstart)
  1770.   {
  1771. - //    _flags &= ~ios::dont_close; 
  1772.       _frozen = 1;
  1773.       if (size == 0)
  1774.       _size = strlen(ptr);
  1775. --- 151,156 ----
  1776. *** 1.3    1992/06/08 20:42:41
  1777. --- timer.cc    1992/07/20 22:22:41
  1778. ***************
  1779. *** 32,39 ****
  1780.   
  1781.   #include <g_config.h>
  1782.   #include <osfcn.h>
  1783. ! #if !defined(_G_HAVE_SYS_RESOURCE) || !defined(RUSAGE_SELF)
  1784.   #define USE_TIMES
  1785.   #include <sys/times.h>
  1786.   #if !defined (HZ) && defined(CLK_TCK)
  1787.   #define HZ CLK_TCK
  1788. --- 32,40 ----
  1789.   
  1790.   #include <g_config.h>
  1791.   #include <osfcn.h>
  1792. ! #if !_G_HAVE_SYS_RESOURCE || !defined(RUSAGE_SELF)
  1793.   #define USE_TIMES
  1794. + #include <sys/param.h>
  1795.   #include <sys/times.h>
  1796.   #if !defined (HZ) && defined(CLK_TCK)
  1797.   #define HZ CLK_TCK
  1798. *** 1.5    1992/06/03 02:12:17
  1799. --- xbitset.cc    1992/07/20 22:22:42
  1800. ***************
  1801. *** 24,30 ****
  1802.   #endif
  1803.   #include <xbitset.h>
  1804.   #include <std.h>
  1805. ! #include <values.h>
  1806.   #include <xobstack.h>
  1807.   #include <xallocri.h>
  1808.   #include <new.h>
  1809. --- 24,30 ----
  1810.   #endif
  1811.   #include <xbitset.h>
  1812.   #include <std.h>
  1813. ! #include <limits.h>
  1814.   #include <xobstack.h>
  1815.   #include <xallocri.h>
  1816.   #include <new.h>
  1817. ***************
  1818. *** 42,48 ****
  1819.   BitSetRep  _nilBitSetRep = { 0, 1, 0, {0} }; // nil BitSets point here
  1820.   
  1821.   #define ONES               ((unsigned short)(~0L))
  1822. ! #define MAXBitSetRep_SIZE  ((1 << (SHORTBITS - 1)) - 1)
  1823.   #define MINBitSetRep_SIZE  16
  1824.   
  1825.   #ifndef MALLOC_MIN_OVERHEAD
  1826. --- 42,48 ----
  1827.   BitSetRep  _nilBitSetRep = { 0, 1, 0, {0} }; // nil BitSets point here
  1828.   
  1829.   #define ONES               ((unsigned short)(~0L))
  1830. ! #define MAXBitSetRep_SIZE  ((1 << (sizeof(short)*CHAR_BIT - 1)) - 1)
  1831.   #define MINBitSetRep_SIZE  16
  1832.   
  1833.   #ifndef MALLOC_MIN_OVERHEAD
  1834. *** 1.4    1992/06/03 02:12:17
  1835. --- xbitstri.cc    1992/07/20 22:22:42
  1836. ***************
  1837. *** 24,30 ****
  1838.   #endif
  1839.   #include <xbitstri.h>
  1840.   #include <std.h>
  1841. ! #include <values.h>
  1842.   #include <xobstack.h>
  1843.   #include <xallocri.h>
  1844.   #include <new.h>
  1845. --- 24,30 ----
  1846.   #endif
  1847.   #include <xbitstri.h>
  1848.   #include <std.h>
  1849. ! #include <limits.h>
  1850.   #include <xobstack.h>
  1851.   #include <xallocri.h>
  1852.   #include <new.h>
  1853. ***************
  1854. *** 43,49 ****
  1855.   BitString _nil_BitString;
  1856.   
  1857.   #define MINBitStrRep_SIZE  8
  1858. ! #define MAXBitStrRep_SIZE  ((1 << (SHORTBITS - 1)) - 1)
  1859.   
  1860.   #ifndef MALLOC_MIN_OVERHEAD
  1861.   #define MALLOC_MIN_OVERHEAD    4
  1862. --- 43,49 ----
  1863.   BitString _nil_BitString;
  1864.   
  1865.   #define MINBitStrRep_SIZE  8
  1866. ! #define MAXBitStrRep_SIZE  ((1 << (sizeof(short)*CHAR_BIT - 1)) - 1)
  1867.   
  1868.   #ifndef MALLOC_MIN_OVERHEAD
  1869.   #define MALLOC_MIN_OVERHEAD    4
  1870. ***************
  1871. *** 148,154 ****
  1872.     if (ss != ds)
  1873.     {
  1874.       int n = (unsigned)(nbits) / BITSTRBITS;
  1875. !     if (n > 0) bcopy((void*)ss, (void*)ds, n * sizeof(short));
  1876.       unsigned short m = ONES << (nbits & (BITSTRBITS - 1));
  1877.       ds[n] = (ss[n] & ~m) | (ds[n] & m);
  1878.     }
  1879. --- 148,154 ----
  1880.     if (ss != ds)
  1881.     {
  1882.       int n = (unsigned)(nbits) / BITSTRBITS;
  1883. !     if (n > 0) memmove((void*)ds, (const void*)ss, n * sizeof(short));
  1884.       unsigned short m = ONES << (nbits & (BITSTRBITS - 1));
  1885.       ds[n] = (ss[n] & ~m) | (ds[n] & m);
  1886.     }
  1887. ***************
  1888. *** 1973,1979 ****
  1889.   
  1890.   void BitString::printon(ostream& os, char f, char t) const
  1891.   {
  1892. -   size_t wrksiz = length() + 2;
  1893.     size_t  xl = rep->len;
  1894.     const unsigned short* ptr = rep->s;
  1895.     register streambuf *sb = os.rdbuf();
  1896. --- 1973,1978 ----
  1897. ***************
  1898. *** 1992,1998 ****
  1899.   {
  1900.     size_t wrksiz = x.length() + 2;
  1901.     char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
  1902. -   char* fmt = fmtbase;
  1903.     ostrstream stream(fmtbase, wrksiz);
  1904.     
  1905.     x.printon(stream, f, t);
  1906. --- 1991,1996 ----
  1907. *** 1.1    1992/03/22 07:42:32
  1908. --- xgetopt.cc    1992/07/20 22:22:44
  1909. ***************
  1910. *** 19,24 ****
  1911. --- 19,34 ----
  1912.   #ifdef __GNUG__
  1913.   #pragma implementation
  1914.   #endif
  1915. + /* AIX requires the alloca decl to be the first thing in the file. */
  1916. + #ifdef __GNUC__
  1917. + #define alloca __builtin_alloca
  1918. + #elif defined(sparc)
  1919. + #include <alloca.h>
  1920. + #elif defined(_AIX)
  1921. + #pragma alloca
  1922. + #else
  1923. + char *alloca ();
  1924. + #endif
  1925.   #include <xgetopt.h>
  1926.   
  1927.   char* GetOpt::nextchar = 0;
  1928. *** 1.5    1992/06/03 02:12:17
  1929. --- xinteger.cc    1992/07/20 22:22:44
  1930. ***************
  1931. *** 32,38 ****
  1932.   #include <std.h>
  1933.   #include <ctype.h>
  1934.   #include <math.h>
  1935. ! #include <values.h>
  1936.   #include <xobstack.h>
  1937.   #include <xallocri.h>
  1938.   #include <new.h>
  1939. --- 32,38 ----
  1940.   #include <std.h>
  1941.   #include <ctype.h>
  1942.   #include <math.h>
  1943. ! #include <limits.h>
  1944.   #include <xobstack.h>
  1945.   #include <xallocri.h>
  1946.   #include <new.h>
  1947. ***************
  1948. *** 44,50 ****
  1949.    as unsigned shorts is changed in the implementation files.
  1950.   */
  1951.   
  1952. ! #define I_SHIFT         SHORTBITS
  1953.   #define I_RADIX         ((unsigned long)(1L << I_SHIFT))
  1954.   #define I_MAXNUM        ((unsigned long)((I_RADIX - 1)))
  1955.   #define I_MINNUM        ((unsigned long)(I_RADIX >> 1))
  1956. --- 44,50 ----
  1957.    as unsigned shorts is changed in the implementation files.
  1958.   */
  1959.   
  1960. ! #define I_SHIFT         (sizeof(short) * CHAR_BIT)
  1961.   #define I_RADIX         ((unsigned long)(1L << I_SHIFT))
  1962.   #define I_MAXNUM        ((unsigned long)((I_RADIX - 1)))
  1963.   #define I_MINNUM        ((unsigned long)(I_RADIX >> 1))
  1964. ***************
  1965. *** 52,59 ****
  1966.   #define I_NEGATIVE      0
  1967.   
  1968.   /* All routines assume SHORT_PER_LONG > 1 */
  1969. ! #define SHORT_PER_LONG  ((unsigned)(((LONGBITS + SHORTBITS - 1) / SHORTBITS)))
  1970. ! #define CHAR_PER_LONG   ((unsigned)(((LONGBITS + CHARBITS - 1) / CHARBITS)))
  1971.   
  1972.   /*
  1973.     minimum and maximum sizes for an IntRep
  1974. --- 52,59 ----
  1975.   #define I_NEGATIVE      0
  1976.   
  1977.   /* All routines assume SHORT_PER_LONG > 1 */
  1978. ! #define SHORT_PER_LONG  ((unsigned)(((sizeof(long) + sizeof(short) - 1) / sizeof(short))))
  1979. ! #define CHAR_PER_LONG   ((unsigned)sizeof(long))
  1980.   
  1981.   /*
  1982.     minimum and maximum sizes for an IntRep
  1983. ***************
  1984. *** 349,355 ****
  1985.   long Itolong(const IntRep* rep)
  1986.   { 
  1987.     if ((unsigned)(rep->len) > (unsigned)(SHORT_PER_LONG))
  1988. !     return (rep->sgn == I_POSITIVE) ? MAXLONG : MINLONG;
  1989.     else if (rep->len == 0)
  1990.       return 0;
  1991.     else if ((unsigned)(rep->len) < (unsigned)(SHORT_PER_LONG))
  1992. --- 349,355 ----
  1993.   long Itolong(const IntRep* rep)
  1994.   { 
  1995.     if ((unsigned)(rep->len) > (unsigned)(SHORT_PER_LONG))
  1996. !     return (rep->sgn == I_POSITIVE) ? LONG_MAX : LONG_MIN;
  1997.     else if (rep->len == 0)
  1998.       return 0;
  1999.     else if ((unsigned)(rep->len) < (unsigned)(SHORT_PER_LONG))
  2000. ***************
  2001. *** 366,372 ****
  2002.     {
  2003.       unsigned long a = rep->s[SHORT_PER_LONG - 1];
  2004.       if (a >= I_MINNUM)
  2005. !       return (rep->sgn == I_POSITIVE) ? MAXLONG : MINLONG;
  2006.       else
  2007.       {
  2008.         a = up(a) | rep->s[SHORT_PER_LONG - 2];
  2009. --- 366,372 ----
  2010.     {
  2011.       unsigned long a = rep->s[SHORT_PER_LONG - 1];
  2012.       if (a >= I_MINNUM)
  2013. !       return (rep->sgn == I_POSITIVE) ? LONG_MAX : LONG_MIN;
  2014.       else
  2015.       {
  2016.         a = up(a) | rep->s[SHORT_PER_LONG - 2];
  2017. ***************
  2018. *** 381,387 ****
  2019.   }
  2020.   
  2021.   // test whether op long() will work.
  2022. ! // careful about asymmetry between MINLONG & MAXLONG
  2023.   
  2024.   int Iislong(const IntRep* rep)
  2025.   {
  2026. --- 381,387 ----
  2027.   }
  2028.   
  2029.   // test whether op long() will work.
  2030. ! // careful about asymmetry between LONG_MIN & LONG_MAX
  2031.   
  2032.   int Iislong(const IntRep* rep)
  2033.   {
  2034. ***************
  2035. *** 1806,1812 ****
  2036.     return r;
  2037.   }
  2038.   
  2039. ! void setbit(Integer& x, long b)
  2040.   {
  2041.     if (b >= 0)
  2042.     {
  2043. --- 1806,1812 ----
  2044.     return r;
  2045.   }
  2046.   
  2047. ! void (setbit)(Integer& x, long b)
  2048.   {
  2049.     if (b >= 0)
  2050.     {
  2051. *** 1.2    1992/05/31 04:14:02
  2052. --- xstring.cc    1992/07/20 22:22:46
  2053. ***************
  2054. *** 25,31 ****
  2055.   #include <xstring.h>
  2056.   #include <std.h>
  2057.   #include <ctype.h>
  2058. ! #include <values.h>
  2059.   #include <new.h>
  2060.   #include <builtin.h>
  2061.   
  2062. --- 25,31 ----
  2063.   #include <xstring.h>
  2064.   #include <std.h>
  2065.   #include <ctype.h>
  2066. ! #include <limits.h>
  2067.   #include <new.h>
  2068.   #include <builtin.h>
  2069.   
  2070. ***************
  2071. *** 109,115 ****
  2072.   
  2073.   // minimum & maximum representable rep size
  2074.   
  2075. ! #define MAXStrRep_SIZE   ((1 << (SHORTBITS - 1)) - 1)
  2076.   #define MINStrRep_SIZE   16
  2077.   
  2078.   #ifndef MALLOC_MIN_OVERHEAD
  2079. --- 109,115 ----
  2080.   
  2081.   // minimum & maximum representable rep size
  2082.   
  2083. ! #define MAXStrRep_SIZE   ((1 << (sizeof(short) * CHAR_BIT - 1)) - 1)
  2084.   #define MINStrRep_SIZE   16
  2085.   
  2086.   #ifndef MALLOC_MIN_OVERHEAD
  2087.